home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
X User Tools
/
X User Tools (O'Reilly and Associates)(1994).ISO
/
sun4c
/
archive
/
tcltk.z
/
tcltk
/
man
/
catn
/
menubar.n
< prev
next >
Wrap
Text File
|
1994-09-20
|
7KB
|
199 lines
tk_menuBar(n) Tk Commands
_________________________________________________________________
NAME
tk_menuBar, tk_bindForTraversal - Support for menu bars
SYNOPSIS
tk_menuBar _f_r_a_m_e ?_m_e_n_u _m_e_n_u ...?
tk_bindForTraversal _a_r_g _a_r_g ...
_________________________________________________________________
DESCRIPTION
These two commands are Tcl procedures in the Tk script
library. They provide support for menu bars. A menu bar is
a frame that contains a collection of menu buttons that work
together, so that the user can scan from one menu to another
with the mouse: if the mouse button is pressed over one
menubutton (causing it to post its menu) and the mouse is
moved over another menubutton in the same menu bar without
releasing the mouse button, then the menu of the first menu-
button is unposted and the menu of the new menubutton is
posted instead. Menus in a menu bar can also be accessed
using keyboard traversal (i.e. by typing keystrokes instead
of using the mouse). In order for an application to use
these procedures, it must do three things, which are
described in the paragraphs below.
First, each application must call tk_menuBar to provide
information about the menubar. The _f_r_a_m_e argument gives the
path name of the frame that contains all of the menu but-
tons, and the _m_e_n_u arguments give path names for all of the
menu buttons associated with the menu bar. Normally _f_r_a_m_e
is the parent of each of the _m_e_n_u's. This need not be the
case, but _f_r_a_m_e must be an ancestor of each of the _m_e_n_u's in
order for grabs to work correctly when the mouse is used to
pull down menus. The order of the _m_e_n_u arguments determines
the traversal order for the menu buttons. If tk_menuBar is
called without any _m_e_n_u arguments, it returns a list con-
taining the current menu buttons for _f_r_a_m_e, or an empty
string if _f_r_a_m_e isn't currently set up as a menu bar. If
tk_menuBar is called with a single _m_e_n_u argument consisting
of an empty string, any menubar information for _f_r_a_m_e is
removed; from now on the menu buttons will function
independently without keyboard traversal. Only one menu bar
may be defined at a time within each top-level window.
The second thing an application must do is to identify the
traversal characters for menu buttons and menu entries.
This is done by underlining those characters using the
-underline options for the widgets. The menu traversal sys-
tem uses this information to traverse the menus under
Tk 1
tk_menuBar(n) Tk Commands
keyboard control (see below).
The third thing that an application must do is to make sure
that the input focus is always in a window that has been
configured to support menu traversal. If the input focus is
none then input characters will be discarded and no menu
traversal will be possible. If you have no other place to |
set the focus, set it to the menubar widget: tk_menuBar |
creates bindings for its _f_r_a_m_e argument to support menu |
traversal. |
The Tk startup scripts configure all the Tk widget classes |
with bindings to support menu traversal, so menu traversal |
will be possible regardless of which widget has the focus.
If your application defines new classes of widgets that sup-
port the input focus, then you should call
tk_bindForTraversal for each of these classes.
Tk_bindForTraversal takes any number of arguments, each of
which is a widget path name or widget class name. It sets
up bindings for all the named widgets and classes so that
the menu traversal system will be invoked when appropriate
keystrokes are typed in those widgets or classes.
MENU TRAVERSAL BINDINGS
Once an application has made the three arrangements
described above, menu traversal will be available. At any
given time, the only menus available for traversal are those
associated with the top-level window containing the input
focus. Menu traversal is initiated by one of the following
actions:
[1] If <F10> is typed, then the first menu button in the
list for the top-level window is posted and the first
entry within that menu is selected.
[2] If <Alt-_k_e_y> is pressed, then the menu button that has
_k_e_y as its underlined character is posted and the first
entry within that menu is selected. The comparison
between _k_e_y and the underlined characters ignores case
differences. If no menu button matches _k_e_y then the
keystroke has no effect.
[3] Clicking mouse button 1 on a menu button posts that
menu and selects its first entry.
Once a menu has been posted, the input focus is switched to
that menu and the following actions are possible:
[1] Typing <ESC> or clicking mouse button 1 outside the
menu button or its menu will abort the menu traversal.
Tk 2
tk_menuBar(n) Tk Commands
[2] If <Alt-_k_e_y> is pressed, then the entry in the posted
menu whose underlined character is _k_e_y is invoked.
This causes the menu to be unposted, the entry's action
to be taken, and the menu traversal to end. The com-
parison between _k_e_y and underlined characters ignores
case differences. If no menu entry matches _k_e_y then
the keystroke is ignored.
[3] The arrow keys may be used to move among entries and
menus. The left and right arrow keys move circularly
among the available menus and the up and down arrow
keys move circularly among the entries in the current
menu.
[4] If <Return> is pressed, the selected entry in the
posted menu is invoked, which causes the menu to be
unposted, the entry's action to be taken, and the menu
traversal to end.
When a menu traversal completes, the input focus reverts to
the window that contained it when the traversal started.
KEYWORDS
keyboard traversal, menu, menu bar, post
Tk 3